package com.uplift.mobile.sys.controller;

import com.uplift.common.result.IResultable;
import com.uplift.common.result.ResultWrapper;
import com.uplift.mobile.sys.model.DictModel;
import com.uplift.mobile.sys.service.IDictService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * 字典相关
 * 
 * @author bcwang
 *
 */
@Controller
@RequestMapping(value = "/sys-dict")
public class DictController {
	public static Log log = LogFactory.getLog(DictController.class);

	@Autowired
	private IDictService dictService;

	/**
	 * 查询消息信息
	 *
	 * @param request
	 * @param dictModel
	 * @return IResultable
	 */
	@RequestMapping(value = "/list")
	@ResponseBody
	public IResultable list(HttpServletRequest request, DictModel dictModel) {
		try {
			List<Map<String, Object>> list = this.dictService.queryDict(dictModel);
			return ResultWrapper.wrapListNoPage(list, ResultWrapper.SUCC, "查询成功");
		} catch (Exception e) {
			log.error(e);
			return ResultWrapper.wrapListNoPage(null, ResultWrapper.FAIL, "查询失败");
		}
	}

}
